package bdqn.t09.service.impl;

import bdqn.t09.dao.AsLogsMapper;
import bdqn.t09.pojo.AsLogs;
import bdqn.t09.service.AsLogsService;
import bdqn.t09.util.Pageinfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class AsLogsServiceImpl implements AsLogsService {

    @Resource
    public AsLogsMapper mapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(AsLogs record) {
        return mapper.insert(record);
    }

    @Override
    public int insertSelective(AsLogs record) {
        return mapper.insertSelective(record);
    }

    @Override
    public AsLogs selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(AsLogs record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(AsLogs record) {
        return mapper.updateByPrimaryKey(record);
    }

    @Override
    public Pageinfo selectAllLogs(Integer currIndex, Integer rows) {
        // 调用工具类的分页类
        Pageinfo pageinfo = new Pageinfo();
        // 更新工具类的当前下标
        pageinfo.setCurrIndex(currIndex);
        // 更新工具类的行
        pageinfo.setRows(rows);
        // 调用mapper层拿到日志的总行数
        int count = mapper.count();
        // 更新工具类的总行数
        pageinfo.setCount(count);
        // 设置起始页
        Integer index = (currIndex - 1) * rows;
        // 调用mapper的分页查询方法
        List<AsLogs> logs = mapper.selectAllLogs(index, rows);
        pageinfo.setList(logs);
        return pageinfo;
    }


}
